<?php


abstract class BaseItemList extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $name;


	
	protected $category;


	
	protected $price;


	
	protected $stock;


	
	protected $pic;


	
	protected $wheel;


	
	protected $color;


	
	protected $gear;


	
	protected $options;


	
	protected $delete_yn = '';

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getName()
	{

		return $this->name;
	}

	
	public function getCategory()
	{

		return $this->category;
	}

	
	public function getPrice()
	{

		return $this->price;
	}

	
	public function getStock()
	{

		return $this->stock;
	}

	
	public function getPic()
	{

		return $this->pic;
	}

	
	public function getWheel()
	{

		return $this->wheel;
	}

	
	public function getColor()
	{

		return $this->color;
	}

	
	public function getGear()
	{

		return $this->gear;
	}

	
	public function getOptions()
	{

		return $this->options;
	}

	
	public function getDeleteYn()
	{

		return $this->delete_yn;
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = ItemListPeer::ID;
		}

	} 
	
	public function setName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = ItemListPeer::NAME;
		}

	} 
	
	public function setCategory($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->category !== $v) {
			$this->category = $v;
			$this->modifiedColumns[] = ItemListPeer::CATEGORY;
		}

	} 
	
	public function setPrice($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->price !== $v) {
			$this->price = $v;
			$this->modifiedColumns[] = ItemListPeer::PRICE;
		}

	} 
	
	public function setStock($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->stock !== $v) {
			$this->stock = $v;
			$this->modifiedColumns[] = ItemListPeer::STOCK;
		}

	} 
	
	public function setPic($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->pic !== $v) {
			$this->pic = $v;
			$this->modifiedColumns[] = ItemListPeer::PIC;
		}

	} 
	
	public function setWheel($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->wheel !== $v) {
			$this->wheel = $v;
			$this->modifiedColumns[] = ItemListPeer::WHEEL;
		}

	} 
	
	public function setColor($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->color !== $v) {
			$this->color = $v;
			$this->modifiedColumns[] = ItemListPeer::COLOR;
		}

	} 
	
	public function setGear($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->gear !== $v) {
			$this->gear = $v;
			$this->modifiedColumns[] = ItemListPeer::GEAR;
		}

	} 
	
	public function setOptions($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->options !== $v) {
			$this->options = $v;
			$this->modifiedColumns[] = ItemListPeer::OPTIONS;
		}

	} 
	
	public function setDeleteYn($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->delete_yn !== $v || $v === '') {
			$this->delete_yn = $v;
			$this->modifiedColumns[] = ItemListPeer::DELETE_YN;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->name = $rs->getString($startcol + 1);

			$this->category = $rs->getInt($startcol + 2);

			$this->price = $rs->getInt($startcol + 3);

			$this->stock = $rs->getInt($startcol + 4);

			$this->pic = $rs->getString($startcol + 5);

			$this->wheel = $rs->getString($startcol + 6);

			$this->color = $rs->getString($startcol + 7);

			$this->gear = $rs->getString($startcol + 8);

			$this->options = $rs->getString($startcol + 9);

			$this->delete_yn = $rs->getString($startcol + 10);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 11; 
		} catch (Exception $e) {
			throw new PropelException("Error populating ItemList object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(ItemListPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			ItemListPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(ItemListPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = ItemListPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += ItemListPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = ItemListPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = ItemListPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getName();
				break;
			case 2:
				return $this->getCategory();
				break;
			case 3:
				return $this->getPrice();
				break;
			case 4:
				return $this->getStock();
				break;
			case 5:
				return $this->getPic();
				break;
			case 6:
				return $this->getWheel();
				break;
			case 7:
				return $this->getColor();
				break;
			case 8:
				return $this->getGear();
				break;
			case 9:
				return $this->getOptions();
				break;
			case 10:
				return $this->getDeleteYn();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = ItemListPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getName(),
			$keys[2] => $this->getCategory(),
			$keys[3] => $this->getPrice(),
			$keys[4] => $this->getStock(),
			$keys[5] => $this->getPic(),
			$keys[6] => $this->getWheel(),
			$keys[7] => $this->getColor(),
			$keys[8] => $this->getGear(),
			$keys[9] => $this->getOptions(),
			$keys[10] => $this->getDeleteYn(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = ItemListPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setName($value);
				break;
			case 2:
				$this->setCategory($value);
				break;
			case 3:
				$this->setPrice($value);
				break;
			case 4:
				$this->setStock($value);
				break;
			case 5:
				$this->setPic($value);
				break;
			case 6:
				$this->setWheel($value);
				break;
			case 7:
				$this->setColor($value);
				break;
			case 8:
				$this->setGear($value);
				break;
			case 9:
				$this->setOptions($value);
				break;
			case 10:
				$this->setDeleteYn($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = ItemListPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCategory($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setStock($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setPic($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setWheel($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setColor($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setGear($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setOptions($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setDeleteYn($arr[$keys[10]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(ItemListPeer::DATABASE_NAME);

		if ($this->isColumnModified(ItemListPeer::ID)) $criteria->add(ItemListPeer::ID, $this->id);
		if ($this->isColumnModified(ItemListPeer::NAME)) $criteria->add(ItemListPeer::NAME, $this->name);
		if ($this->isColumnModified(ItemListPeer::CATEGORY)) $criteria->add(ItemListPeer::CATEGORY, $this->category);
		if ($this->isColumnModified(ItemListPeer::PRICE)) $criteria->add(ItemListPeer::PRICE, $this->price);
		if ($this->isColumnModified(ItemListPeer::STOCK)) $criteria->add(ItemListPeer::STOCK, $this->stock);
		if ($this->isColumnModified(ItemListPeer::PIC)) $criteria->add(ItemListPeer::PIC, $this->pic);
		if ($this->isColumnModified(ItemListPeer::WHEEL)) $criteria->add(ItemListPeer::WHEEL, $this->wheel);
		if ($this->isColumnModified(ItemListPeer::COLOR)) $criteria->add(ItemListPeer::COLOR, $this->color);
		if ($this->isColumnModified(ItemListPeer::GEAR)) $criteria->add(ItemListPeer::GEAR, $this->gear);
		if ($this->isColumnModified(ItemListPeer::OPTIONS)) $criteria->add(ItemListPeer::OPTIONS, $this->options);
		if ($this->isColumnModified(ItemListPeer::DELETE_YN)) $criteria->add(ItemListPeer::DELETE_YN, $this->delete_yn);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(ItemListPeer::DATABASE_NAME);

		$criteria->add(ItemListPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setName($this->name);

		$copyObj->setCategory($this->category);

		$copyObj->setPrice($this->price);

		$copyObj->setStock($this->stock);

		$copyObj->setPic($this->pic);

		$copyObj->setWheel($this->wheel);

		$copyObj->setColor($this->color);

		$copyObj->setGear($this->gear);

		$copyObj->setOptions($this->options);

		$copyObj->setDeleteYn($this->delete_yn);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new ItemListPeer();
		}
		return self::$peer;
	}

} 